<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Add cookies</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.httprequest.html">HttpRequest</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="httprequest.addheaders.html">HttpRequest::addHeaders</a></div>
 <div class="up"><a href="class.httprequest.html">HttpRequest</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="httprequest.addcookies" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">HttpRequest::addCookies</h1>
  <p class="verinfo">(PECL pecl_http &gt;= 0.10.0)</p><p class="refpurpose"><span class="refname">HttpRequest::addCookies</span> &mdash; <span class="dc-title">Add cookies</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-httprequest.addcookies-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">bool</span> <span class="methodname"><strong>HttpRequest::addCookies</strong></span>
    ( <span class="methodparam"><span class="type">array</span> <code class="parameter">$cookies</code></span>
   )</div>


  <p class="para rdfs-comment">
   Add custom cookies.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara"><a href="http.request.options.html" class="link">request 选项</a> <em>encodecookies</em> 控制 cookie 值是否应被
<span class="function"><a href="function.urlencode.html" class="function">urlencode()</a></span> 编码。</span></p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">影响任意请求方法。</span></p></blockquote>

 </div>

 <div class="refsect1 parameters" id="refsect1-httprequest.addcookies-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">cookies</code></em></dt>

     <dd>

      <p class="para">
       an associative array containing any cookie name/value pairs to add
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-httprequest.addcookies-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 


 


 <div class="refsect1 examples" id="refsect1-httprequest.addcookies-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4258">
    <p><strong>Example #1 A <span class="function"><strong>HttpRequest::addCookies()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$r&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">HttpRequest</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$r</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">addCookies</span><span style="color: #007700">(<br />&nbsp;&nbsp;&nbsp;&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"cookie_name"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"cookie&nbsp;value"</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;)<br />);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-httprequest.addcookies-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="httprequest.setcookies.html" class="function" rel="rdfs-seeAlso">HttpRequest::setCookies()</a> - Set cookies</span></li>
   </ul>
  </p>
 </div>



</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.httprequest.html">HttpRequest</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="httprequest.addheaders.html">HttpRequest::addHeaders</a></div>
 <div class="up"><a href="class.httprequest.html">HttpRequest</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
